package model;

import base.BaseModel;
import base.BaseObserver;
import base.ResultCallBack;
import bean.LunTanJiYanBean;
import bean.LunTanOffRecyBean;
import bean.LunTanSchoolTabBean;
import io.reactivex.Observable;
import jiyun.com.yiyanmeng.http.HttpManager;
import jiyun.com.yiyanmeng.http.MySerivce;
import utils.RxUtil;

/**
 * Created by Windows on 2019/11/5.
 */

public class LunTanModel extends BaseModel {
    public void getData(final ResultCallBack<LunTanSchoolTabBean> resultCallBack) {
        MySerivce serivce = HttpManager.getInstance().getSerivce(MySerivce.base_URL,MySerivce.class);
        Observable <LunTanSchoolTabBean> sctabbean = serivce.sctabbean();
        sctabbean.compose(RxUtil.<LunTanSchoolTabBean>changeThread())
                .subscribe(new BaseObserver<LunTanSchoolTabBean>() {
                    @Override
                    public void onSuccess(LunTanSchoolTabBean lunTanSchoolTabBean) {
                        resultCallBack.onSuccess(lunTanSchoolTabBean);
                    }

                    @Override
                    public void onFail(String error) {
                        resultCallBack.onFail(error);
                    }
                });
    }

    public void getOffData(final ResultCallBack <LunTanOffRecyBean> resultCallBack) {
        MySerivce serivce = HttpManager.getInstance().getSerivce(MySerivce.base_URL, MySerivce.class);
        Observable <LunTanOffRecyBean> offbean = serivce.offbean();
        offbean.compose(RxUtil.<LunTanOffRecyBean>changeThread())
                .subscribe(new BaseObserver <LunTanOffRecyBean>() {
                    @Override
                    public void onSuccess(LunTanOffRecyBean lunTanOffRecyBean) {
                        resultCallBack.onSuccess(lunTanOffRecyBean);
                    }

                    @Override
                    public void onFail(String error) {
                        resultCallBack.onFail(error);
                    }
                });
    }

    public void getJiYanData(final ResultCallBack <LunTanJiYanBean> resultCallBack, int page) {
        MySerivce serivce = HttpManager.getInstance().getSerivce(MySerivce.base_URL, MySerivce.class);
        serivce.janyanbean("",page).compose(RxUtil.<LunTanJiYanBean>changeThread())
                .subscribe(new BaseObserver <LunTanJiYanBean>() {
                    @Override
                    public void onSuccess(LunTanJiYanBean lunTanJiYanBean) {
                        resultCallBack.onSuccess(lunTanJiYanBean);
                    }

                    @Override
                    public void onFail(String error) {
                        resultCallBack.onFail(error);
                    }
                });
    }
}
